#include<bits/stdc++.h>
#define N 100005
#define maxL 1000005
#define inf 0x3f3f3f3f
#define int long long
using namespace std;
int T;
int n,m,L,V;
int d[N],v[N],a[N];
int p[N];
int lst[maxL],lst2[maxL],pt=1,maxp=0;
int ans1;
unordered_map<int,int>mp;
// bitset<N>vis;
struct Node{
    int l,r;
    bool operator <(const Node &a)const{
        return l==a.l?r<a.r:l<a.l;
    }
}node[N];
int cnt;
// priority_queue<int,vector<int>,greater<int> >q;
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        
        // vis.reset();
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            // cout<<d[i]<<" "<<v[i]<<" "<<a[i]<<" "<<i<<endl;
        }
        // cout<<n<<endl;
        maxp=0;
        for(int i=1;i<=m;i++){
            cin>>p[i];
            // cout<<p[i]<<" ";
            mp[p[i]]=i;
            maxp=max(maxp,p[i]);
            
        }   
        p[m+1]=-1;
        // mp[-1]=0;
        // pt=1;
        pt=1;
        for(int i=0;i<=L;i++){
            if(p[pt]==i)
                pt++;
            lst[i]=p[pt];
            // cout<<p[pt]<<" ";
        }
        ans1=0;
        cnt=0;
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(d[i]<=maxp&&v[i]>V){
                    ans1++;
                    node[++cnt]=Node{mp[lst[d[i]]],m};
                }
            }
            else if(a[i]<0){
                int d2=lst[d[i]];
                int vv=v[i]*v[i]+2*a[i]*(d2-d[i]);
                if(vv>V*V){
                    ans1++;
                    node[++cnt]=Node{mp[lst[d[i]]],mp[lst[(V*V-v[i]*v[i])/(2*(a[i]))+d[i]]]};
                }
            }
            else if(a[i]>0){
                int vv2=v[i]*v[i]+2*a[i]*(maxp-d[i]);
                if(vv2>(V*V)){
                    ans1++;
                    node[++cnt]=Node{mp[lst[(V*V-v[i]*v[i])/(2*a[i])+1+d[i]]],m};
                }
            }
        }
        int ans2=0;
        sort(node+1,node+cnt+1);
        int ad=-1;
        int minn=inf,c=0;
        for(int i=1;i<=cnt;i++){
            // cout<<node[i].l<<" "<<node[i].r<<endl;
            if(c==0||minn>=node[i].l)
                minn=min(minn,node[i].r),c++;
            else{
                minn=inf,c=1;
                ans2++;
                // if(node[i].r!=node[i].l)
                    minn=min(minn,node[i].r);
                
            }
        }
        if(c!=0)
            ans2++;
        // while(!q.empty())
        //     q.pop();
        cout<<ans1<<" "<<m-ans2<<endl;
    }
    return 0;
}